
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<%
	request.setCharacterEncoding("utf-8");
	String userno = session.getAttribute("userno").toString();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>公告管理</title>

<script type="text/javascript" src="easyui/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css"
	href="easyui/themes/default/easyui.css" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="css/loads.css" rel="stylesheet" type="text/css" />
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>


	<div class="button" style="margin:15px auto; width:600px;">
		<a class="easyui-linkbutton" id='delete' iconCls="icon-cut">批量删除通告</a>
		<a class="easyui-linkbutton" id="edit" iconCls="icon-edit">发布通告</a>
	</div>
	<div id="table">
		<table class="note" id="query_note" cellpadding="0" cellspacing="0"
			style="width: 810px">

		</table>
	</div>
	<div id="reportdd"></div>

	<script type="text/javascript">
		$(document)
				.ready(
						function() {
							$("#query_note")
									.datagrid(
											{
												url : 'public_report/query_note.jsp?',
												columns : [ [ {
													field : 'cut',
													checkbox : true,
													width : 80
												}, {
													field : 'infoid',
													title : '编号',
													width : 50,
													sortable : true
												}, {
													field : 'name',
													title : '发布者',
													width : 60,
													sortable : true
												}, {
													field : 'title',
													title : '标题',
													width : 320,
													align : 'center'
												}, {
													field : 'detail',
													title : '详情',
													width : 50
												}, {
													field : 'notetime',
													title : '发布日期',
													width : 140,
													sortable : true,
													align : 'center'
												}, {
													field : 'readnum',
													title : '浏览次数',
													width : 70,
													sortable : true,
													align : 'center'
												}, {
													field : 'isappend',
													title : '是否附件',
													width : 80,
													sortable : true,
													align : 'center'
												}, ] ],
												pagination : true,
												onClickCell : function(
														rowIndex, field, value) {
													if (field == 'detail') {
														var row = $(
																"#query_note")
																.datagrid(
																		'getSelections');
														if (!row
																|| row.length == 0) {
															alert("没有选上数据!");
														}
														var id = row[0].infoid;
														// alert(id);     
														$("#reportdd").dialog(
																		{
																			title : "公告详情",
																			zIndex : 9001,
																			width : 700,
																			height : 500,
																			top : 150,
																			left : 400,
																			cache : false,
																			resizable : true,
																			href : 'public_report/teacher/infodetail.jsp?id='+ id //！！！！后台请注意获取的时候检测一下
																		});
									 $('#reportdd').dialog('refresh', 'public_report/teacher/infodetail.jsp?id='+ id);									
													}

												}

											});

							/*添加处理*/
							$("#edit").click(function() {
							
							
								$("#reportdd").dialog({
									title : "发布公告",
									zIndex : 9001,
									width : 680,
									height : 400,
									top : 150,
									left : 300,
									cache : false,
									href : 'public_report/add_note.jsp'
								});
							$('#reportdd').dialog('refresh', 'public_report/add_note.jsp');

							});
							/*删除处理'public_report/teacher/delete_note.jsp'*/

							$('#delete')
									.click(
											function() {
												var ids = [];
												var rows = $('#query_note')
														.datagrid(
																'getSelections');
												if (!rows || rows.length == 0) {
													$.messager.alert('提示',
															'请选择要删除的数据!',
															'info');
													return;
												}
												$.each(rows, function(i, n) {
													ids.push(n.infoid);
												});
												$.messager
														.confirm(
																'提示',
																'是否删除选中数据?',
																function(r) {
																	if (!r) {
																		return;
																	}
																	//alert(ids);
																	$
																			.ajax({
																				url : 'public_report/delete_note.jsp', /*删除处理界面,传到后台的是所有选中的行号组成的数字数组*/
																				data : 'selectrows='
																						+ ids,
																				dataType : 'text',
																				success : function(
																						msg) {
																					if (msg == 'ok') {
																						//alert("删除成功");
																						var tab = $(
																								".easyui-tabs")
																								.tabs(
																										'getSelected');
																						;
																						$(
																								".easyui-tabs")
																								.tabs(
																										'update',
																										{
																											tab : tab,
																											options : {
																												cache : false,
																												href : 'public_report/teacher/public_report.jsp',
																											}
																										}); /*更新面板*/

																					} else {
																						alert("删除失败");
																					}
																				}

																			});

																});
											});

						});

		/***/
	</script>
</body>
</html>
